#import "CTRefuseHeader.h"
@interface CTRefuseHeader ()
@property (nonatomic, strong) UIImageView *icon;
@end
@implementation CTRefuseHeader
-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if(self){
        self.contentView.backgroundColor = [UIColor whiteColor];
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(topAction)];
        [self.contentView addGestureRecognizer:tapGesture];
        [self createUI];
    }
    return self;
}
-(void)topAction{
    if(self.tapClick){
        self.tapClick();
    }
}
-(void)createUI {
    self.contentView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.icon];
    [self.contentView addSubview:self.titleLabel];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.left.mas_equalTo(Ratio(16));
        make.width.height.mas_equalTo(Ratio(16));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.icon);
        make.left.mas_equalTo(self.icon.mas_right).offset(Ratio(10));
        make.right.mas_equalTo(self.contentView).offset(-Ratio(10));
    }];
}
- (void)setIsSelect:(BOOL)isSelect {
    _isSelect = isSelect;
    _icon.image = isSelect ? [UIImage imageNamed:@"login_sel"] : [UIImage imageNamed:@"login_unsel"];
}
- (UIImageView *)icon {
    if (!_icon) {
        _icon = [[UIImageView alloc] init];
        _icon.contentMode = UIViewContentModeScaleToFill;
        _icon.userInteractionEnabled = NO;
        _icon.image = [UIImage imageNamed:@"login_unsel"];
    }
    return _icon;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 1;
        _titleLabel.font = kFontRatio(14);
        _titleLabel.textColor = [UIColor color30323E];
        _titleLabel.text = @"";
    }
    return _titleLabel;
}
@end
